<?php
	
	class UserAction extends BaseAction {

		public function __construct() {
			parent::__construct(true);
		}
		
		public function get() {
			Logger::debug($this, "Carregando usuario");
			$params = Scope::getDefaultParameters();

			if ( $params != null )
				Logger::debug($this, "Carregando usuario com o id : " . $params[0]);
			else
				Logger::debug($this, "Id n�o informado");
		}
		
		public function search() {
			Logger::debug($this, "Executando o m�todo search");
		}

		public function login() {
			Logger::debug($this, "Efetuando o login");
			$login = Scope::loadVar("login");
			$password = Scope::loadVar("password");
			
			if( !Validator::isValid($login) ) 
			
			
			
			if( Validator::isValid($login) && Validator::isValid($password) ) {
				$user = "marcio";
				$pass = "senha";
				
				if( $login == $user && $password == $pass ) {
					$user = new User();
					$user->setLogin($login);
					$user->setPassword($password);
					SecurityManager::login($user);
				} else {
					$this->addMessage("Informações inválidas", Constants::MESSAGE_TYPE_ERROR);
				}
			} else {
				$this->addMessage("Informações inválidas", Constants::MESSAGE_TYPE_ERROR);
			}			
		}
		
		public function logout() {
			Logger::debug($this, "Efetuando o logout");
			SecurityManager::logout();			
		}
	}
?>